package cn.wch.blelib.host.gattNameResolver;

import java.util.HashMap;
import java.util.UUID;

/**
 * 特征描述
 */
public class GATT_Descriptor {
    public static GATT_Descriptor gatt_descriptor;
    private static final String ZERO="0000";
    private static final String UUID_TAIL="-0000-1000-8000-00805f9b34fb";
    private static HashMap<String,GATT_uuidNmae> map=new HashMap<>();
    static {
        map.put(ZERO+"2900"+UUID_TAIL,new GATT_uuidNmae("Characteristic Extended Properties","特征扩展属性"));
        map.put(ZERO+"2901"+UUID_TAIL,new GATT_uuidNmae("Characteristic User Description","特征用户描述"));
        map.put(ZERO+"2902"+UUID_TAIL,new GATT_uuidNmae("Client Characteristic Configuration","客户端特征配置"));
        map.put(ZERO+"2903"+UUID_TAIL,new GATT_uuidNmae("Server Characteristic Configuration","服务器特征配置"));
        map.put(ZERO+"2904"+UUID_TAIL,new GATT_uuidNmae("Characteristic Presentation Format","特征描述格式"));
        map.put(ZERO+"2905"+UUID_TAIL,new GATT_uuidNmae("Characteristic Aggregate Format","特征汇总格式"));
        map.put(ZERO+"2906"+UUID_TAIL,new GATT_uuidNmae("Valid Range","有效范围"));
        map.put(ZERO+"2907"+UUID_TAIL,new GATT_uuidNmae("External Report Reference","外部报告参考"));
        map.put(ZERO+"2908"+UUID_TAIL,new GATT_uuidNmae("Report Reference","报告参考"));
        map.put(ZERO+"2909"+UUID_TAIL,new GATT_uuidNmae("Number of Digitals","数字数量"));
        map.put(ZERO+"290a"+UUID_TAIL,new GATT_uuidNmae("Value Trigger Setting","值触发器设置"));
        map.put(ZERO+"290b"+UUID_TAIL,new GATT_uuidNmae("Environmental Sensing Configuration","环境感应配置"));
        map.put(ZERO+"290c"+UUID_TAIL,new GATT_uuidNmae("Environmental Sensing Measurement","环境传感测量"));
        map.put(ZERO+"290d"+UUID_TAIL,new GATT_uuidNmae("Environmental Sensing Trigger Setting","环境感应触发设定"));
        map.put(ZERO+"290e"+UUID_TAIL,new GATT_uuidNmae("Time Trigger Setting","时间触发设定"));
    }

    public static GATT_uuidNmae getDescriptorType(UUID uuid){
        return getDescriptorType(uuid.toString().toLowerCase());
    }
    public static GATT_uuidNmae getDescriptorType(String uuid){
        GATT_uuidNmae result=null;
        if(uuid.length()==4){
            result = map.get(ZERO+uuid.toLowerCase()+UUID_TAIL);
        }else if(uuid.length()==8){
            result = map.get(uuid.toLowerCase()+UUID_TAIL);
        }else if(uuid.length()==(8+UUID_TAIL.length())){
            result = map.get(uuid.toLowerCase());
        }
        if(result == null) result = new GATT_uuidNmae("Unknown Descriptor","未知描述");
        return result;
    }
}
